import request from '@/router/axios';


export const getList = (keyWord, createNames, pageNo, pageSize) => { // 查询社交自动化列表
  return request({
    url: '/api/blade-marketing/marketingEmailRule/page',
    method: 'get',
    params: {
      keyWord,
      createNames,
      pageNo,
      pageSize
    }
  })
}
export const getTargetGroup = () => { // 获取目标用户组
  return request({
    url: '/api/blade-custom/custType/roots',
    method: 'get'
  })
}
export const getTimeRule = () => { // 获取目标用户组
  return request({
    url: '/api/blade-public/dictTimeInterval',
    method: 'get',
    params: {
      intervalType: 'EMAIL_RULE'
    }
  })
}
export const saveRules = (row) => { // 保存自动化规则
  return request({
    url: '/api/blade-marketing/marketingEmailRule',
    method: 'post',
    data: row
  })
}
export const updateRule = (row) => {//修改
  return request.put(`/api/blade-marketing/marketingEmailRule/${row.id}`, row)
}
export const changeShare = (id, en) => { //共享开关
  return request.put(`/api/blade-marketing/marketingEmailRule/${id}/share/${en}`)

}
export const changeUse = (id, en) => { //启用开关
  return request.put(`/api/blade-marketing/marketingEmailRule/${id}/enable/${en}`)

}
export const copyRule = (id, name) => { //复制
  return request.put(`/api/blade-marketing/marketingEmailRule/${id}/copy?name=${name}`)
}
export const deleteTemplate = (id) => { // 删除邮件模板
  return request({
    url: `/api/blade-marketing/marketingEmailRule/${id}`,
    method: 'delete'
  })
}
export const mailTemplateDetail = (id) => { // 查询单个详情
  return request({
    url: `/api/blade-marketing/marketingEmailRule/${id}`,
    method: 'get'
  })
}

//获取指定分组
export const getGroup = () => { // 查询单个详情 /blade-custom/custType/queryMarket
  return request({
    url: `/api/blade-custom/custType/queryMarket`,
    method: 'get',
  })
}
export const getNextMan = () => {
  return request({
    url: '/api/blade-marketing/marketingEmailRule/createNames',
    method: 'get'
  })
}
